<!--
 * Description: 报价系列新增页面
 * Company: 联宝（合肥）电子科技有限公司
 * Author: Jian.Yang
 * Date: 2021/01/04 14:08
-->

<template>
  <div>
    <!--数据表单-->
    <el-form label-width="100px" :model="formData" size="mini">
      <el-row>
        <!--FD编号-->
        <el-col :span="12">
          <el-form-item :label="$t('FdData.fdId')">
            <el-input v-model="formData.fdId" v-blur:fdId="formData" clearable />
          </el-form-item>
        </el-col>

        <!--FD版本-->
        <el-col :span="12">
          <el-form-item :label="$t('FdData.version')">
            <el-input v-model="formData.version" v-blur:version="formData" clearable />
          </el-form-item>
        </el-col>

        <!--FD名称-->
        <el-col :span="12">
          <el-form-item :label="$t('FdData.fdName')">
            <el-input v-model="formData.fdName" v-blur:fdName="formData" clearable />
          </el-form-item>
        </el-col>

        <!--FD报价期限-->
        <el-col :span="12">
          <el-form-item :label="$t('FdData.expiresDay')">
            <el-input-number
              v-model="formData.expiresDay"
              clearable
              controls-position="right"
              :min="0"
            />
          </el-form-item>
        </el-col>

        <!--参考配置-->
        <el-col :span="12">
          <el-form-item :label="$t('FdData.baseConfig')">
            <el-input v-model="formData.baseConfig" v-blur:baseConfig="formData" clearable />
          </el-form-item>
        </el-col>

        <!--参考模型-->
        <el-col :span="12">
          <el-form-item :label="$t('FdData.baseModel')">
            <el-input v-model="formData.baseModel" v-blur:baseModel="formData" clearable />
          </el-form-item>
        </el-col>

        <!--参照专案编号-->
        <el-col :span="12">
          <el-form-item :label="$t('FdData.baseProjectId')">
            <el-input v-model="formData.baseProjectId" v-blur:baseProjectId="formData" clearable />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>

    <span style="display: block; text-align: center; margin-top: 5px">
      <!--取消按钮-->
      <el-button size="medium" @click="cancel">{{ $t('button.cancel') }}</el-button>
      <!--保存按钮-->
      <el-button :loading="isRequesting" size="medium" type="primary" @click="save">
        {{ $t('button.save') }}
      </el-button>
    </span>
  </div>
</template>

<script>
import { fdAdd } from '@/api/serverbom/fd'

export default {
  name: 'ServerDataAdd',
  props: {},
  data() {
    return {
      // 正在查询
      isRequesting: false,
      formData: {}
    }
  },
  methods: {
    async save() {
      try {
        this.isRequesting = true
        await fdAdd(this.formData, { msgSuccess: true, msgError: true })
        this.$emit('save')
      } catch (error) {
        console.log(error)
      } finally {
        this.isRequesting = false
      }
    },
    cancel() {
      this.$emit('cancel')
    }
  }
}
</script>
